package com.kurtphpr.sistema.vendas;

import org.hibernate.HibernateException;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;

@SuppressWarnings("deprecation")
public class HibernateUtil
{
    
	private static SessionFactory sessionFactory;
    private static ServiceRegistry serviceRegistry;
	public static Object getSession;

    static
    {
        try
        {
            Configuration configuration = new Configuration().configure();

            serviceRegistry = ( new ServiceRegistryBuilder().applySettings(configuration
            					.getProperties())).getBootstrapServiceRegistry();
            sessionFactory = configuration.buildSessionFactory(serviceRegistry);
        }
        catch (HibernateException he)
        {
            System.err.println("Erro no Sistema " + he);
            throw new ExceptionInInitializerError(he);
        }
    }

    public static SessionFactory getSessionFactory()
    {
        return sessionFactory;
    } 
}